$OpenBSD: patch-gcc_config_alpha_alpha_c,v 1.1 2014/01/18 11:38:22 pascal Exp $
--- gcc/config/alpha/alpha.c.orig	Sun Apr 22 03:30:31 2007
+++ gcc/config/alpha/alpha.c	Sat Dec  7 10:58:29 2013
@@ -226,6 +226,10 @@ alpha_handle_option (size_t code, const char *arg, int
       target_flags |= MASK_IEEE_CONFORMANT;
       break;
 
+    case OPT_mno_ieee:
+      target_flags &= ~(MASK_IEEE_WITH_INEXACT|MASK_IEEE_CONFORMANT);
+      break;
+
     case OPT_mtls_size_:
       if (value != 16 && value != 32 && value != 64)
 	error ("bad value %qs for -mtls-size switch", arg);
@@ -287,12 +291,19 @@ override_options (void)
       flag_pic = 0;
     }
 
+#if defined(OPENBSD_NATIVE) || defined(OPENBSD_CROSS)
+  if (TARGET_FLOAT_VAX)
+    alpha_fprm = ALPHA_FPRM_NORM;
+  else
+    alpha_fprm = ALPHA_FPRM_DYN;
+#else
   /* On Unicos/Mk, the native compiler consistently generates /d suffices for
      floating-point instructions.  Make that the default for this target.  */
   if (TARGET_ABI_UNICOSMK)
     alpha_fprm = ALPHA_FPRM_DYN;
   else
     alpha_fprm = ALPHA_FPRM_NORM;
+#endif
 
   alpha_tp = ALPHA_TP_PROG;
   alpha_fptm = ALPHA_FPTM_N;
@@ -482,11 +493,17 @@ override_options (void)
   if (!g_switch_set)
     g_switch_value = 8;
 
+#ifdef OPENBSD_NATIVE
+  /* Make -fpic behave as -fPIC unless -msmall-data is specified. */
+  if (flag_pic == 2 && TARGET_SMALL_DATA)
+    warning (0, "-fPIC used with -msmall-data");
+#else
   /* Infer TARGET_SMALL_DATA from -fpic/-fPIC.  */
   if (flag_pic == 1)
     target_flags |= MASK_SMALL_DATA;
   else if (flag_pic == 2)
     target_flags &= ~MASK_SMALL_DATA;
+#endif
 
   /* Align labels and loops for optimal branching.  */
   /* ??? Kludge these by not doing anything if we don't optimize and also if
@@ -7598,94 +7615,134 @@ alpha_expand_prologue (void)
 
      Note that we are only allowed to adjust sp once in the prologue.  */
 
-  if (frame_size <= 32768)
+  if (flag_stack_check || STACK_CHECK_BUILTIN)
     {
-      if (frame_size > 4096)
+      if (frame_size <= 32768)
 	{
-	  int probed;
+	  if (frame_size > 4096)
+	    {
+	      int probed;
 
-	  for (probed = 4096; probed < frame_size; probed += 8192)
-	    emit_insn (gen_probe_stack (GEN_INT (TARGET_ABI_UNICOSMK
-						 ? -probed + 64
-						 : -probed)));
+	      for (probed = 4096; probed < frame_size; probed += 8192)
+		emit_insn (gen_probe_stack (GEN_INT (TARGET_ABI_UNICOSMK
+						     ? -probed + 64
+						     : -probed)));
 
-	  /* We only have to do this probe if we aren't saving registers.  */
-	  if (sa_size == 0 && frame_size > probed - 4096)
-	    emit_insn (gen_probe_stack (GEN_INT (-frame_size)));
+	      /* We only have to do this probe if we aren't saving
+		 registers.  */
+	      if (sa_size == 0 && frame_size > probed - 4096)
+		emit_insn (gen_probe_stack (GEN_INT (-frame_size)));
+	    }
+
+	  if (frame_size != 0)
+	    FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
+					GEN_INT (TARGET_ABI_UNICOSMK
+						 ? -frame_size + 64
+						 : -frame_size))));
 	}
+      else
+	{
+	  /* Here we generate code to set R22 to SP + 4096 and set R23 to the
+	     number of 8192 byte blocks to probe.  We then probe each block
+	     in the loop and then set SP to the proper location.  If the
+	     amount remaining is > 4096, we have to do one more probe if we
+	     are not saving any registers.  */
 
-      if (frame_size != 0)
-	FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
-				    GEN_INT (TARGET_ABI_UNICOSMK
-					     ? -frame_size + 64
-					     : -frame_size))));
-    }
-  else
-    {
-      /* Here we generate code to set R22 to SP + 4096 and set R23 to the
-	 number of 8192 byte blocks to probe.  We then probe each block
-	 in the loop and then set SP to the proper location.  If the
-	 amount remaining is > 4096, we have to do one more probe if we
-	 are not saving any registers.  */
+	  HOST_WIDE_INT blocks = (frame_size + 4096) / 8192;
+	  HOST_WIDE_INT leftover = frame_size + 4096 - blocks * 8192;
+	  rtx ptr = gen_rtx_REG (DImode, 22);
+	  rtx count = gen_rtx_REG (DImode, 23);
+	  rtx seq;
 
-      HOST_WIDE_INT blocks = (frame_size + 4096) / 8192;
-      HOST_WIDE_INT leftover = frame_size + 4096 - blocks * 8192;
-      rtx ptr = gen_rtx_REG (DImode, 22);
-      rtx count = gen_rtx_REG (DImode, 23);
-      rtx seq;
+	  emit_move_insn (count, GEN_INT (blocks));
+	  emit_insn (gen_adddi3 (ptr, stack_pointer_rtx,
+				 GEN_INT (TARGET_ABI_UNICOSMK
+					  ? 4096 - 64 : 4096)));
 
-      emit_move_insn (count, GEN_INT (blocks));
-      emit_insn (gen_adddi3 (ptr, stack_pointer_rtx,
-			     GEN_INT (TARGET_ABI_UNICOSMK ? 4096 - 64 : 4096)));
+	  /* Because of the difficulty in emitting a new basic block this
+	     late in the compilation, generate the loop as a single insn.  */
+	  emit_insn (gen_prologue_stack_probe_loop (count, ptr));
 
-      /* Because of the difficulty in emitting a new basic block this
-	 late in the compilation, generate the loop as a single insn.  */
-      emit_insn (gen_prologue_stack_probe_loop (count, ptr));
+	  if (leftover > 4096 && sa_size == 0)
+	    {
+	      rtx last = gen_rtx_MEM (DImode, plus_constant (ptr, -leftover));
+	      MEM_VOLATILE_P (last) = 1;
+	      emit_move_insn (last, const0_rtx);
+	    }
 
-      if (leftover > 4096 && sa_size == 0)
-	{
-	  rtx last = gen_rtx_MEM (DImode, plus_constant (ptr, -leftover));
-	  MEM_VOLATILE_P (last) = 1;
-	  emit_move_insn (last, const0_rtx);
-	}
+	  if (TARGET_ABI_WINDOWS_NT)
+	    {
+	      /* For NT stack unwind (done by 'reverse execution'), it's
+		 not OK to take the result of a loop, even though the value
+		 is already in ptr, so we reload it via a single operation
+		 and subtract it to sp.
 
-      if (TARGET_ABI_WINDOWS_NT)
-	{
-	  /* For NT stack unwind (done by 'reverse execution'), it's
-	     not OK to take the result of a loop, even though the value
-	     is already in ptr, so we reload it via a single operation
-	     and subtract it to sp.
+		 Yes, that's correct -- we have to reload the whole constant
+		 into a temporary via ldah+lda then subtract from sp.  */
 
-	     Yes, that's correct -- we have to reload the whole constant
-	     into a temporary via ldah+lda then subtract from sp.  */
+	      HOST_WIDE_INT lo, hi;
+	      lo = ((frame_size & 0xffff) ^ 0x8000) - 0x8000;
+	      hi = frame_size - lo;
 
-	  HOST_WIDE_INT lo, hi;
-	  lo = ((frame_size & 0xffff) ^ 0x8000) - 0x8000;
-	  hi = frame_size - lo;
+	      emit_move_insn (ptr, GEN_INT (hi));
+	      emit_insn (gen_adddi3 (ptr, ptr, GEN_INT (lo)));
+	      seq = emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx,
+					   ptr));
+	    }
+	  else
+	    {
+	      seq = emit_insn (gen_adddi3 (stack_pointer_rtx, ptr,
+					   GEN_INT (-leftover)));
+	    }
 
-	  emit_move_insn (ptr, GEN_INT (hi));
-	  emit_insn (gen_adddi3 (ptr, ptr, GEN_INT (lo)));
-	  seq = emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx,
-				       ptr));
+	  /* This alternative is special, because the DWARF code cannot
+	     possibly intuit through the loop above.  So we invent this
+	     note it looks at instead.  */
+	  RTX_FRAME_RELATED_P (seq) = 1;
+	  REG_NOTES (seq)
+	    = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
+				 gen_rtx_SET (VOIDmode, stack_pointer_rtx,
+				   gen_rtx_PLUS (Pmode, stack_pointer_rtx,
+						 GEN_INT (TARGET_ABI_UNICOSMK
+							  ? -frame_size + 64
+							  : -frame_size))),
+				 REG_NOTES (seq));
 	}
+    }
+  else
+    {
+      if (frame_size <= 32768)
+	{
+	  if (frame_size != 0)
+	    FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
+					GEN_INT (TARGET_ABI_UNICOSMK
+						 ? -frame_size + 64
+						 : -frame_size))));
+	}
       else
 	{
-	  seq = emit_insn (gen_adddi3 (stack_pointer_rtx, ptr,
-				       GEN_INT (-leftover)));
+	  rtx count = gen_rtx_REG (DImode, 23);
+	  rtx seq;
+ 
+	  emit_move_insn (count, GEN_INT (TARGET_ABI_UNICOSMK
+					  ? -frame_size + 64
+					  : -frame_size));
+	  seq = emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
+				       count));
+ 
+	  /* This alternative is special, because the DWARF code cannot
+	     possibly intuit through the loop above.  So we invent this
+	     note it looks at instead.  */
+	  RTX_FRAME_RELATED_P (seq) = 1;
+	  REG_NOTES (seq)
+	    = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
+				 gen_rtx_SET (VOIDmode, stack_pointer_rtx,
+				   gen_rtx_PLUS (Pmode, stack_pointer_rtx,
+						 GEN_INT (TARGET_ABI_UNICOSMK
+							  ? -frame_size + 64
+							  : -frame_size))),
+				 REG_NOTES (seq));
 	}
-
-      /* This alternative is special, because the DWARF code cannot
-         possibly intuit through the loop above.  So we invent this
-         note it looks at instead.  */
-      RTX_FRAME_RELATED_P (seq) = 1;
-      REG_NOTES (seq)
-        = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
-			     gen_rtx_SET (VOIDmode, stack_pointer_rtx,
-			       gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-					     GEN_INT (TARGET_ABI_UNICOSMK
-						      ? -frame_size + 64
-						      : -frame_size))),
-			     REG_NOTES (seq));
     }
 
   if (!TARGET_ABI_UNICOSMK)
